#ifndef CLUSTERMSG_H
#define CLUSTERMSG_H

#include "clustertype.h"

//#define CLUSTER_MAX_NODE_NUM              10
#define CLUSTER_MAX_AREA_NUM              3
//#define CLUSTER_MAX_PATH_NUM              10
//#define CLUSTER_MAX_MSG_CONTAINER_NUM     10

#define NEWLINE (QString("\n        "))
#define PRINT_HEADER (QString("\n    ")+__FUNCTION__+QString(":->"))

enum Cluster_Qgc_Cmd_IE
{
    /*State Message*/
    CLUSTER_QGC_CONFIG_TARGET_INFO = 0,
    CLUSTER_QGC_CONFIG_FLIGHT_INFO = 1,
    CLUSTER_QGC_CMD_SELF_CHECK = 10,
    CLUSTER_QGC_CMD_ACTIVE_POWER = 11,
    CLUSTER_QGC_CMD_TAKEOFF = 12,
    CLUSTER_QGC_CMD_STANDBY = 13,
    CLUSTER_QGC_CMD_RETURN_PICTURE = 14,
    CLUSTER_QGC_CMD_POINT_WORK = 15,
    CLUSTER_QGC_CMD_ADD_TARGET = 16,
    CLUSTER_QGC_CMD_DELETE_TARGET = 17,
    CLUSTER_QGC_CMD_USER_CONTROL = 21,
    CLUSTER_QGC_CMD_LAND = 22,


    CLUSTER_UAV_STATE_REPORT = 30,
    CLUSTER_UAV_TARGET_SHARE = 31,
};

struct Cluster_Msg_Header
{
    cUint8 uDestID;
    cUint8 uSourceID;
    cUint8 uMsgID;
    cUint8 uReserved;
    cUint32 uTimeStamp;
    cUint16 uMsgLength;
};

struct QGC_Config_Target_Info
{
    cUint8 uDeveiceID;
    cUint8 uTargetAreaNum;
    cUint8 auTargetType[CLUSTER_MAX_AREA_NUM];
    cUint8 auAssumeTargetNum[CLUSTER_MAX_AREA_NUM];
    Cluster_Point astTargetGPSArea[CLUSTER_MAX_AREA_NUM][4];
};

struct QGC_Config_Flight_Info
{
    cUint8 uDeveiceID;
    cUint8 uZDBType;
    cUint8 uRefHeight;
    cUint8 uRefVelocity;
    Cluster_Point stInitialGpsPos;
    Cluster_Point stInitialAttitude;
    Cluster_Point stPickupArea;
};

struct QGC_To_Cluster_All
{
    Cluster_Msg_Header stMsgHeader;
    QGC_Config_Target_Info stConfigTargetInfo;
    QGC_Config_Flight_Info stConfigFlightInfo;
};

struct Uav_State_To_Qgc
{
    cUint8 uDeveiceID;
    cUint8 uDeveiceType;
    cUint8 uHwState;
    cUint8 uSpeed;
    cUint8 uWorkState;
    cUint8 uAllocTargetId;
    cUint8 uElectric;
    //cUint32 uLongitude;//double * 1000000
    //cUint32 uLatitude;
    //cUint32 uAltitude;
    //cUint32 uYaw;
    cFloat64 uLongitude;//double * 1000000
    cFloat64 uLatitude;
    cFloat64 uAltitude;
    cFloat64 uYaw;
};

struct Uav_Target_To_Qgc
{
    cUint8 uDeveiceID;
    cUint8 uTargetNum;
    cUint8 uTargetState;
    cUint8 uTargetID[CLUSTER_MAX_TARGET_NUM];
    cUint8 uTargetType[CLUSTER_MAX_TARGET_NUM];
    cUint8 uTargetConf[CLUSTER_MAX_TARGET_NUM];
    //cUint32 uTargetLon[CLUSTER_MAX_TARGET_NUM];
    //cUint32 uTargetLat[CLUSTER_MAX_TARGET_NUM];
    //cUint32 uTargetAlt[CLUSTER_MAX_TARGET_NUM];
    cFloat64 uTargetLon[CLUSTER_MAX_TARGET_NUM];
    cFloat64 uTargetLat[CLUSTER_MAX_TARGET_NUM];
    cFloat64 uTargetAlt[CLUSTER_MAX_TARGET_NUM];
};

struct Cluster_To_Qgc_All
{
    cUint8 auMapArray[CLUSTER_MAX_NODE_NUM];
    Uav_Target_To_Qgc stTargetInfo;
    Uav_State_To_Qgc stUavInfo[CLUSTER_MAX_NODE_NUM];
};


extern void fnCluster_mh_StructToArray(std_msgs::UInt8MultiArray &auMsgOut, cInt8* InMsgBuf, cUint32 uInMsgLen);
extern bool fnCluster_mh_ArrayToStruct(std_msgs::UInt8MultiArrayConstPtr auInMsg, cInt8* OutMsgBuf, cUint32 ucheckMsgLen);

#endif // CLUSTERMSG_H
